package com.my;

import javax.servlet.http.HttpSessionActivationListener;
import javax.servlet.http.HttpSessionBindingEvent;
import javax.servlet.http.HttpSessionBindingListener;
import javax.servlet.http.HttpSessionEvent;
import java.io.Serializable;

/**
 * Created by YJH on 2017/7/14 10:12.
 */
public class Customer implements HttpSessionBindingListener, HttpSessionActivationListener, Serializable {

    @Override
    public void valueBound(HttpSessionBindingEvent httpSessionBindingEvent) {
        System.out.println("绑定到Session");

        Object value = httpSessionBindingEvent.getValue();
        System.out.println(value == this);
        System.out.println(httpSessionBindingEvent.getName());
    }

    @Override
    public void valueUnbound(HttpSessionBindingEvent httpSessionBindingEvent) {
        System.out.println("从Session中解除绑定");
    }

    @Override
    public void sessionWillPassivate(HttpSessionEvent httpSessionEvent) {
        System.out.println("从内存中写到磁盘中...");
    }

    @Override
    public void sessionDidActivate(HttpSessionEvent httpSessionEvent) {
        System.out.println("从磁盘中读取出来...");
    }
}
